#!/usr/bin/env python3
import numpy as np
from scipy.signal import correlate2d

dim = 20
img_hori = np.zeros((dim, dim))
for i in range(0, dim, 4):
	img_hori[i, :]= np.ones(dim)
	img_hori[i+1, :]= np.ones(dim)

img_vert = img_hori.T

print('img-hori')
print(img_hori)
print('img-vert')
print(img_vert)

filt = np.array([[-1, 0, 1]]*3)
print('filt')
print(filt)

res_hori = correlate2d(img_hori, filt, mode='valid')
print('res-hori')
print(res_hori)

res_vert = correlate2d(img_vert, filt, mode='valid')
print('res-vert')
print(res_vert)
